﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Globalization;

namespace comm_num_tp1
{
    #region common enum
    enum GpGGAStreamItem { StreamIden, StreamTime, StreamLat, StreamLon, StreamFix, StreamSatQty, StreamDop, StramAltitude, StreamMsl, StreamTimeStamp, StreamDgpsStation, StreamChecksum };
    enum GpGSVStreamItem { StreamIden, StreamCompletStream, StreamNo, StreamVisibleSat, StreamSatIden, StreamElevDegSat, StreamAzimuthSat, StreamSignalStrength };
    enum GpRMCStreamItem { StreamIden, StreamTime, StreamWarning, StreamLat, StreamLon, StreamSpeed, StreamBearing, StreamTimeStamp, StreamDeclMagnetDeg, StreamChecksum };
    #endregion

    public class GpsStream
    {
        #region private variable
        DateTime _streamTime;
        DateTime _streamTimestamp;
        #endregion

        #region accessors
        public string StreamIden { get; set;}
        
        public string StreamTime
        {
            get
            {
                string streamtime = "";
                if (_streamTime != null)
                   streamtime = _streamTime.ToString("HHmmss");
                return streamtime;
            }
            set
            {
                if (!String.IsNullOrEmpty(value))
                {
                    string preTime = value.Substring(0, 2) + ":" + value.Substring(2, 2) + ":" + value.Substring(4, 2);
                    _streamTime = DateTime.ParseExact(preTime, "HH:mm:ss", CultureInfo.InvariantCulture);
                }
            }
        }

        public string StreamTimestamp
        {
            get
            {
                string streamtimestamp = "";
                if (_streamTimestamp != null)
                    streamtimestamp = _streamTimestamp.ToString("HHmmss");
                return streamtimestamp;
            }
            set
            {
                if (!String.IsNullOrEmpty(value))
                {
                    string preTime = value.Substring(0, 2) + ":" + value.Substring(2, 2) + ":" + value.Substring(4, 2);
                    _streamTimestamp = DateTime.ParseExact(preTime, "HH:mm:ss", CultureInfo.InvariantCulture);
                }
            }
        }

        public string StreamCoolTime
        {
            get
            {
                string coolTime = "";
                if (_streamTime != null)
                    coolTime = _streamTime.ToString("HH:mm:ss");
                return coolTime;
            }
        }

        public string StreamCoolTimeStamp
        {
            get
            {
                string coolTimeStamp = "";
                if (_streamTimestamp != null)
                    coolTimeStamp = _streamTimestamp.ToString("HH:mm:ss");
                return coolTimeStamp;
            }
        }

        public bool IsGsvList { get; set; }
        #endregion
    }
}
